package edu.hunau.cxb19.oop.class32.tcp.v2;

import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

/**
 *
 * @author hb
 *
 *         2020-04-21 15:36:28
 */
public class ClinetTcp {

	public static void main(String[] args) throws Exception {
		Socket client = new Socket("localhost", 8088);
		System.out.println("和服务端建立连接:" + client);
		// 向服务器发送消息,获得输出流
		OutputStream os = client.getOutputStream();
		// 写出数据
		PrintWriter pw = new PrintWriter(os);
		pw.println("[客户端]:我是一个客户端,nihao?");
		// 关闭资源
		pw.close();
		client.close();

	}
}
